
package com.zsrt.lianxi;



import java.util.Scanner;

import org.junit.Test;


public class Print {

	@Test
	public void testLingXing() throws Exception {
		
		//上半部分
		for(int h=1;h<=4;h++){
				
			for(int kg=1; kg<=4-h;kg++){
				System.out.print(" ");
			}
			for(int xx=1;xx<=2*h-1;xx++){
				System.out.print("*");
			}
			System.out.println();
		}
		//下半部分
		
	}
	
	@Test
	public void test01() throws Exception {
		
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入一个数字   1~4 ：");
		String  num = sc.next();
		sc.close();
		switch (num) {
		case "老板":
			System.out.println("坐小车回家");
			break;
		case "白领":
			System.out.println("坐高铁回家");
			break;
		case "普工":
			System.out.println("坐硬座回家");
			break;
		default:
			
			System.out.println("zoulu回家");
			break;
		}
	}
	
	@Test
	public void test03() throws Exception {
		
		Scanner sc = new Scanner(System.in);
		int age = sc.nextInt();
		int b =18;
		//age>=b? System.out.println("成年人"):System.out.println("成年人");
		System.out.println("" + (age>=18? "成年人":"未成年人"));
	}
	
	@Test
	public void QPTest() throws Exception {
		
		int[] arrays = new int[]{97, 23, 45, 67,89};
		quickSort(arrays,0,arrays.length-1);
		
	}

	private void quickSort(int[] arrays,int begin,int end) {
		int i= begin;
		int j = end;
		int key = arrays[begin];
		if(j<=i){
			return;
		}
		System.out.println();
		while(true){
			while(j>i){
				if(arrays[j]<key){
					int temp = arrays[i];
					arrays[i]=arrays[j];
					arrays[j]=temp;
					break;
				}else{
					j--;
				}
			}
			while(i<j){
				if(arrays[i]>key){
					int temp = arrays[j];
					arrays[j] = arrays[i];
					arrays[i] = temp;
					break;
				}else{
					i++;
				}
			}
			if(i==j){
				for(int n:arrays){
					System.out.print(" \t "+n);
				}
				System.out.println();
				break;
			}
		}
		begin = i;
		
		quickSort(arrays, 0, begin);
		quickSort(arrays, begin+1, end);
	}
	
	
}
